FTP Commands

back to section start!
  OpusFTP doesn't have any ARexx commands, but Greg wanted something simple,
so here I am :)

  The number of commands in the OpusFTP module has been reduced in the latest
version because the need for some of them has been made obsolete.

  In previous versions of OpusFTP you needed commands that could allow you
access to so-called 'hidden' files or directories.  For example, on Aminet
you have a file named 'RECENT', and also a directory named 'recent'.  Both
appear in the Aminet 'root' directory, but because they had the same name
only one would be displayed in a lister, (remember, AmigaDOS is case-
insensitive, even though the target filesystem might not have been).

  Due to the fact that listers can now be case-sensitive, there is now no
need for the following commands: FTPCD, FTPCopy, FTPDelete, and FTPRename.

  The OpusFTP module has no ARexx interface, but the commands it adds to Opus
can be accessed as though they were normal Opus commands like All, None, etc.

  To access them you just call them as you would for any other normal Opus
internal command, that is, you preceed them with the  command  command.

  The following commands are all that are available through the OpusFTP
module interface.

 FTPAdd            FTPAddressBook    FTPCommand        FTPConnect     
 FTPOptions        FTPQuit           FTPSetVar      

  The ftpaddressbook command doesn't do anything amazing, all it does is
open the FTP address book so that you can edit or connect to an entry.

  Example:


 /* FTPAddressbook.dopus5 */ 
options results
address 'DOPUS.1'
command ftpaddressbook
address command wait 3
command ftpquit
exit

  This is probably even easier than the  dopus back  and  dopus front
commands.

  The  FTPConnect  command instructs OpusFTP to connect to the specified
site, using a username/password if provided, changing to a specified
directory, and listing it, if asked.

  NOTE: The following example will require a TCP/IP connection to the
        InterNet in order to execute, and it will try to download the latest
        Aminet INDEX of directory biz/dopus to RAM:.  Do not execute it if
        you don't have a stack running or believe it will cause financial
        hardship.

  With this example, because we know there will be a file called INDEX in the
biz/dopus directory, (standard Aminet directory index), there is no need to
actually have the lister scan the directory in.  This can save time, (and
save you some money too ;-) and we can do this by adding the flag noscan
to the ftpconnect command.

  Example:


 /* FTPConnect.dopus5 */ 
lf = '0a'x
options results
address 'DOPUS.1'
'command wait ftpconnect host wuarchive.wustl.edu dir /pub/aminet/biz/dopus noscan recon'
handle = result
text = 'We should now be connected to Aminet'
dopus request '"'text'" OK'
text = 'I like this directory, in fact I''ll think'||lf||,
       'I''ll add it to your address book :)'
dopus request '"'text'" Yes?|No!'
if rc ~= 0 then command ftpadd
lister set handle source
'command original wait copy INDEX TO RAM:'
lister close handle
command ftpquit
exit

  Directory Opus is fully multitasking and multithreading, just because you
have closed the lister that was your FTP connection does not mean that the
FTP process has been ended.

  If you no longer require the FTP module loaded, then issuing an  FTPQuit 
command will remove it from the task list.  This will also stop a requester
opening when you quit your TCP/IP stack.

  For example, supposing you had a script that did the following:

1) Start Miami.
2) Log on to ISP.
3) Start OpusFTP.
4) Log in to an Aminet site and download the 'RECENT' file.
5) Close the FTP connection.
6) Tell Miami to log off and quit.
7) Analyse RECENT file for specific keywords indicating interesting stuff,
   and present them in the dopus viewer for you.

  If you didn't tell the OpusFTP module to quit, then when you asked Miami to
quit, Miami would put up a requester similar to the following:

The following applications
are still using Miami:

 ftp_addressbook

Proceed anyway?

   Yes   No

  Your script would halt, waiting for the requester to be acknowledged.  This
would mean that step 7, which analyses the 'RECENT' file for interesting
stuff would never happen, until you acknowledged Miami's requester.

  In fact while we're at it, why don't we create a simple script to do the
above steps.  Since this will be simple, practically no error checking will
be used, you could expand upon this script to add it and any other features,
like downloading the interesting files as well.

  If you're not using Miami v3, which provides the assign 'Miami:', then
change the line:

address command 'Miami:Miami'

to point to where you keep it.

/* ParseAminetRecent.dopus5 */
lf = '0a'x
interesting = 'biz/dopus hard/hack util/dtype sex beer money'

options results
address 'DOPUS.1'

if ~show('p','MIAMI.1') then do
  address command 'Miami:Miami'
  WaitForPort 'MIAMI.1'
  if ~show('p','MIAMI.1') then do
    dopus request '"Unable to run Miami!" OK'
    exit
    end
  end

flag = 0
address 'MIAMI.1' 'ISONLINE'
if rc then flag = 1             /* see if Miami is already online */
do while flag = 0
  address 'MIAMI.1' 'ONLINE'
  address 'MIAMI.1' 'ISONLINE'
  if rc then flag = 2
end

lister new
handle = result
lister set handle source
'command wait ftpconnect lister 'handle' host ftp.livewire.com.au dir /pub/aminet noscan recon'

command source handle original wait 'copy name=RECENT to=RAM:'

lister close handle
command ftpquit
if flag = 2 then do
  address 'MIAMI.1' 'OFFLINE'  /* Leave Miami online if it */
  address 'MIAMI.1' 'QUIT'     /* was already              */
  end

if ~open('infile','RAM:RECENT','R') then do
  dopus request '"Cannot open RECENT file!" OK'
  exit
  end

text = 'Found these interesting files:'
do while ~eof('infile')
  aline = readln('infile')
  do i = 1 to words(interesting)
    if index(aline, word(interesting,i)) > 0 then do
      text = text||lf||aline
      leave
      end
  end
end
call close('infile')

dopus request '"'text'" OK'
exit

DOpus PLUS - giving you that bit extra...